<%@ page import="com.sunelec.pojo.Users" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html lang="en">
<head>
    <title>账号管理</title>
    <meta name="renderer" content="webkit" />
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link href="${pageContext.request.contextPath}/static/css/font-awesome.css" rel="stylesheet" />
    <link href="${pageContext.request.contextPath}/static/css/bootstrap.min.css" rel="stylesheet" />
    <link href="${pageContext.request.contextPath}/static/css/style.css" rel="stylesheet" />
    <link href="${pageContext.request.contextPath}/static/css/idManage.css" rel="stylesheet" />
    <script src="${pageContext.request.contextPath}/static/js/jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/idManage.js"></script>
</head>
<body>
<div class="top">
    <div class="top-left">
        <div class="kong"></div>
        <div class="logo">
            <img src="${pageContext.request.contextPath}/static/imgs/logo3.png">
        </div>
    </div>
    <div class="top-right">
        <ul class="list">
            <li><a href="${pageContext.request.contextPath}/powerCenter.action?username=${username}">电站中心</a></li>
            <li><a href="checkCenter.jsp">运维中心</a></li>
            <li><a href="${pageContext.request.contextPath}/InReportCenter">报表中心</a></li>
            <li><a href="${pageContext.request.contextPath}/centralizedControl">展示中心</a></li>
            <% if(session.getAttribute("users")!=null){
                Users users = (Users)session.getAttribute("users");
            %>
            <% if(users.getType()==1){%>
            <li><a href="${pageContext.request.contextPath}/InidManage">账号管理</a></li>
            <% }%>
            <% } %>
            <li><a href="${pageContext.request.contextPath}/checkOut.action" ><span class="fa fa-user"></span></a></li>
        </ul>
    </div>
</div>
<div class="main">
    <div class="center">
        <div class="block1">
            <div class="title1">
                <span>账号管理</span>
            </div>
        </div>
        <div class="block2">
            <div class="box1">
                <div class="boxTitle">
                    <span>二级账号建立</span>
                </div>
                <div class="boxContent">
                    <form action="TwoLevelUserRegister" method="post" id="form1">
                        <div class="name input">
                            <label for="name" class="label1">用户名：</label><input type="text" id="name" name="username" placeholder="username" class="input1">
                        </div>
                        <div class="password input">
                            <label for="password" class="label1">密&nbsp;&nbsp;&nbsp;码：</label><input type="password" id="password" name="password" placeholder="12345678" class="input1">
                        </div>
                        <div class="confirm input">
                            <label for="password2" class="label1">确认密码：</label><input type="password" id="password2" placeholder="12345678" class="input1">
                        </div>
                        <div id="error">${msg}</div>
                        <div class="input">
                            <input type="button" class="submit btn" onclick="beforeSubmit()" style="color: white" value="点击创建">
                        </div>
                    </form>
                </div>
            </div>
            <div class="box2">
                <div class="boxTitle">
                    <span>二、三级账号关联</span>
                </div>
                <div class="boxContent">
                    <ul class="nav nav-tabs">
                        <li id="nav1" class="active"><a href="#one"data-toggle="tab">二级账号</a></li>
                        <li id="nav2"><a href="#two"data-toggle="tab">三级账号</a></li>
                    </ul>
                    <div class="form">
                        <div class="tab-content">
                            <div class="tab-pane active fade in" id="one">
                                <table class="table">
                                    <tr>
                                        <td>二级账号</td>
                                        <td>账号密码</td>
                                        <td>操作</td>
                                        <td></td>
                                    </tr>
                                    <c:forEach items="${user_2.list}" var="u2">
                                        <form action="updateUser?pn2=${pn2}&pn3=${pn3}&temp=2&id=${u2.userId}" method="post">
                                            <tr>
                                                <td><input type="text" name="username" value="${u2.usersname}" style="color: black"></td>
                                                <td><input type="text" name="password" value="${u2.password}" style="color: black"></td>
                                                <td><input type="submit" value="保存"  style="color: black"></td>
                                                <c:if test="${updateId==u2.userId}">
                                                    <td>${error}</td>
                                                </c:if>
                                                <c:if test="${updateId!=u2.userId}">
                                                    <td>&nbsp;</td>
                                                </c:if>
                                            </tr>
                                        </form>
                                    </c:forEach>
                                </table>
                                <div class="page">
                                    <ul class="pagination text-center pagination-xs">
                                        <li class="bg"><a href="InidManage?pn2=1&pn3=${pn3}&temp=2">首页</a></li>
                                        <c:if test="${user_2.hasPreviousPage }">
                                            <li class="lg">
                                                <a href="InidManage?pn2=${user_2.pageNum-1}&pn3=${pn3}&temp=2" aria-label="Previous">&laquo;</a>
                                            </li>
                                        </c:if>
                                        <li class="active bg"><a href="#">${user_2.pageNum}</a></li>
                                        <c:if test="${user_2.hasNextPage }">
                                            <li class="lg">
                                                <a href="InidManage?pn2=${user_2.pageNum+1 }&pn3=${pn3}&temp=2" aria-label="Next">&raquo;</a>
                                            </li>
                                        </c:if>
                                        <li class="bg"><a href="InidManage?pn2=${user_2.pages}&pn3=${pn3}&temp=2">末页</a></li>
                                    </ul>
                                </div>
                            </div>
                            <div class="tab-pane fade" id="two">
                                <table class="table">
                                    <tr>
                                        <td>三级账号</td>
                                        <td>账号密码</td>
                                        <td>操作</td>
                                        <td></td>
                                    </tr>
                                    <c:forEach items="${user_3.list}" var="u3">
                                        <form action="updateUser?pn2=${pn2}&pn3=${pn3}&temp=3&id=${u3.userId}" method="post">
                                            <tr>
                                                <td><input type="text" name="username" value="${u3.usersname}" style="color: black"></td>
                                                <td><input type="text" name="password" value="${u3.password}" style="color: black"></td>
                                                <td><input type="submit" value="保存" style="color: black"></td>
                                                <c:if test="${updateId==u3.userId}">
                                                    <td>${error}</td>
                                                </c:if>
                                                <c:if test="${updateId!=u3.userId}">
                                                    <td>&nbsp;</td>
                                                </c:if>
                                            </tr>
                                        </form>
                                    </c:forEach>
                                </table>
                                <div class="page">
                                    <ul class="pagination pagination-xs text-center">
                                        <li class="bg"><a href="InidManage?pn2=${pn2}&pn3=1&temp=3">首页</a></li>
                                        <c:if test="${user_3.hasPreviousPage }">
                                            <li class="lg">
                                                <a href="InidManage?pn2=${pn2}&pn3=${user_3.pageNum-1}&temp=3" aria-label="Previous">&laquo;</a>
                                            </li>
                                        </c:if>
                                        <li class="active bg"><a href="#">${user_3.pageNum}</a></li>
                                        <c:if test="${user_3.hasNextPage }">
                                            <li class="lg">
                                                <a href="InidManage?pn2=${pn2}&pn3=${user_3.pageNum+1 }&temp=3" aria-label="Next">&raquo;</a>
                                            </li>
                                        </c:if>
                                        <li class="bg"><a href="InidManage?pn2=${pn2}&pn3=${user_3.pages}&temp=3">末页</a></li>
                                    </ul>
                                </div>
                            </div>
                        </div>

                        <div class="button">
                            <a href="InAssociate" class="btn">关联账号</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>

<script>
    var num=${temp};
    var one = document.getElementById("one")
    var two = document.getElementById("two")
    var nav1 = document.getElementById("nav1")
    var nav2 = document.getElementById("nav2")
    if (num==2){
        one.classList.add("active","in");
        nav1.classList.add("active");
        two.classList.remove("active","in");
        nav2.classList.remove("active");
    }
    if (num==3){
        two.classList.add("active","in");
        nav2.classList.add("active");
        one.classList.remove("active","in");
        nav1.classList.remove("active");
    }
</script>
</body>
</html>
